<?php

/*
 * 快递公司业务类
 */

class Application_Model_shipType extends Application_Model_DomainObject {

    protected $_id; //序号
    protected $_name; //名称
    protected $_comment; //备注
    protected $_image; //公司图标
    protected $_code; //编码
    protected $_isUrl; //是否查询结果是URL,;//API接口是否只能拿出查询地址
    protected $_type; //类型.0国际快递,1国内快递
    protected $_word; //名称首字母,用于做索引
    protected $_disabled; //是否失效
    protected $_emId; //扭门Id
    protected $_createdAt; //创建时间

    /**
     * 上门取件的默认渠道顺丰的id
     */

    const Default_VisitingSf = 21;
    const TYPE_CN_SHIP = 1; //1国内快递
    const TYPE_ES_SHIP = 0; //0国际快递

    /**
     * 返回数据持久化对象
     * @return Application_Model_StoreItem
     */

    private static function getDb() {
        return new Application_Model_DbTable_shipType();
    }

    /*
     * 获取所有快递公司列表
     */

    public static function getAll() {
        $result = Application_Model_shipType::getDb()->getAll();
        return $result;
    }

    /*
     * 
     */

    public static function getbyType($type) {
        $result = Application_Model_shipType::getDb()->getbyType($type);
        return $result;
    }

    /**
     * 根据编码返回一个快递公司
     * @param type $code
     * @return Application_Model_shipType 
     */
    public static function getByCode($code) {
        return Application_Model_shipType::getDao()->queryOne(array('code' => $code));
    }

    public static function getById($id) {
        return Application_Model_shipType::getDao()->queryOne(array('id' => $id));
    }

    public static function getByWord($word) {
        return Application_Model_shipType::getDao()->queryAll(array('word' => $word));
    }

    public static function getByName($lname) {
        return Application_Model_shipType::getDao()->queryOne(array("name" => $lname));
    }

    public static function getFilteds($quick, $isDisable, $pagesize, $pageindex) {
        $where = array();
        $and = "";
        if ($quick != "") {
            $where[$and . " name like "] = "%" . $quick . "%";
            $and = " and ";
        }
        if ($isDisable !== "") {
            $where[$and . " disabled = "] = $isDisable;
            $and = " and ";
        }

        return self::getDao()->queryPage($where, " id desc ", $pagesize, $pageindex);
    }

}

?>
